package com.neuedu.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.domain.Userinfo;
import com.neuedu.service.UserinfoService;
import com.neuedu.service.impl.UserinfoServiceImpl;

/**
 * Servlet implementation class UserAnsHomeServlet
 */
//@WebServlet("/user/anshome")
public class UserAnsHomeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");		
		UserinfoService us = new UserinfoServiceImpl();
		Userinfo user = us.homeCheck(Integer.parseInt(id));
		request.setAttribute("user", user);
		List<Map<String,Object>> artlist = us.selectArticle(Integer.parseInt(id));
		request.setAttribute("artlist", artlist);
		List<Map<String,Object>> minelist = us.selectMineaAns(Integer.parseInt(id));
		request.setAttribute("minelist", minelist);
		request.getRequestDispatcher("/jsp/user/home.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
